1. Field of the Invention
The present invention relates to a method and apparatus which calculates a similarity between an inputted image and a model image, and to a method apparatus for detecting a position of the inputted image, using the above-calculated similarity.
2. Discussion of the Related Art
A method of calculating similarity between gray scale images, which uses a normalized mutual correlation method, has previously been proposed. That method is robust with respect to alternating lighting conditions and is described in the text, Handbook of Image Analysis by Takagi et. al., Tokyo Univ. Publishing Association (Jan. 17, 1991).
FIG. 23 shows a prior art image processing apparatus which employs this method. The image processing apparatus of FIG. 23 is equipped with a camera 1 which inputs an image of objects, an A/D converter 2 which converts the inputted analog image to a digital image, an image memory 3 which stores the digital image, a D/A converter 4 which converts the digital image to an analog signal for displaying the image on a CRT-display 5, an address/data bus 6, a timing control unit 7, a CPU 8 which processes and controls the inputted image, the display, and the calculation of a similarity between inputted and model images, a memory 9 which stores image data for a similarity calculation, a similarity unit 10 for performing the similarity calculations, and a threshold decision unit 11.
The similarity unit 10 is equipped with a covariance unit 12, a normal deviation unit 13, a multiplication unit 14 and a division unit 15 as shown in FIG. 24.
The camera 1 receives an inputted image and outputs an analog image signal. The analog image signal is converted to a digital image signal by A/D converter 2, synchronized with a timing signal from the timing control unit 7. The converted digital image signal is stored in the image memory 3 as a gray scale image. The CRT-display 5 displays the inputted image which is stored in the image memory 3, after the inputted image is converted to an analog image signal by the D/A converter 4.
The similarity unit 10 calculates the similarity between the inputted image stored in the image memory 3, and a model (reference) image which is stored in the memory 9. The calculated similarity is also stored in the memory 9. The threshold decision unit 11 compares the calculated similarity stored in the memory 9 with a predetermined threshold value, and outputs OK or NG (good or no good) decision based on the comparison. The output OK/NG is also stored in the memory 9. Each functional unit shown in FIG. 23 communicates with other units via the address/data bus 6. The CPU 8 generates a start up command for each unit.
The similarity unit 10 calculates the similarity (CC) as follows: ##EQU1## and a size of an inputted image and a model image is represented by (mx,my), a density of inputted image is represented by I(x,y), and a density of the model image is represented by M(x,y).
The density of the inputted image I(x,y) and the density of the model image M(x,y) are transmitted to the similarity unit 10. The covariance unit 12 calculates the covariance between I(x,y) and M(x,y) as follows: ##EQU2## The normal deviation unit 13 calculates the normal deviation of I(x,y) as follows: ##EQU3## The normal deviation unit 13 also calculates the normal deviation of M(x,y) as follows: ##EQU4## The multiplication unit 14 multiplies the normal deviation of I(x,y) by the normal deviation of M(x,y) as follows: ##EQU5## The division unit 15 then calculates the normalized mutual correlation (CC). The calculated normalized mutual correlation (CC) is stored in the memory 9 as the measure of similarity between the inputted image and the model image.
The method of calculating the normalized mutual correlation does not change even if a density level and scaling change for the image. However, in the case of a non-linear relation of shading and a changed background between the inputted image and the model image, the existing FIGS. 23, 24 image processing apparatus cannot recognize a pattern stably. It is because the ratio of multiplication of each normal deviation to a covariance between model image and inputted image is so big that the measure of similarity becomes small. For example, the similarity between the inputted image, which has a background partly changed related to the background of the model image, and the model image is calculated to be a low similarity. Thus, even though with only a background shading change, for example, in one of the images, the image processing apparatus cannot recognize a pattern stably because with such a change the similarity is determined to be low.